package spring.boot.shiro.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import spring.boot.shiro.entity.User;
import spring.boot.shiro.repository.UserRep;

import java.util.List;

/**
 * Created by Administrator on 2018/6/10.
 */
@Service
public class UserService {

    @Autowired
    private UserRep userRep;

    public List<User> findAll(){
        return userRep.findAll();
    }

    public void addUser(User user){
        userRep.save(user);
    }

    public void updateUser(User user){
        userRep.save(user);
    }

    public User findById(Integer id){
        return userRep.getOne(id);
    }

    public void deleteUser(Integer id){
        userRep.deleteById(id);
    }

    public User findByName(String userName){
        return userRep.findByName(userName);
    }

}
